using System;
using System.Configuration;
using NWrapper.Attributes;
using NWrapper.Config;

namespace NWrapper.Cache
{
	/// <summary>
	/// Singleton implementation of a cache that does nothing.
	/// </summary>
	[Singleton]
	public class NullCache : ICache
	{
		private static readonly NullCache _instance = new NullCache();

		/// <summary>
		/// Static constructor to enforce singleton.
		/// </summary>
		static NullCache()
		{
		}

		/// <summary>
		/// Gets the singleton instance for the cache.
		/// </summary>
		public static NullCache Instance
		{
			get { return _instance; }
		}

		#region ICache Members
		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="settings">The cache settings.</param>
		public void Initialize(CacheSettings settings)
		{
			//nothing to do
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="key">Doesn't matter.</param>
		/// <returns>null</returns>
		public object this[object key]
		{
			get { return null; }
			set { /*do nothing*/ }
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="key">Doesn't matter.</param>
		/// <returns>null</returns>
		public object Get(object key)
		{
			return null;
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="key">Doesn't matter.</param>
		/// <param name="value">Doesn't matter.</param>
		public void Set(object key, object value)
		{
			// do nothing
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="key">Doesn't matter.</param>
		/// <param name="value">Doesn't matter.</param>
		/// <param name="timeToExpire">Doesn't matter.</param>
		public void Set(object key, object value, TimeSpan timeToExpire)
		{
			// do nothing
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="key">Doesn't matter.</param>
		/// <param name="value">Doesn't matter.</param>
		/// <param name="expiration">Doesn't matter.</param>
		public void Set(object key, object value, DateTime expiration)
		{
			// do nothing
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="key">Doesn't matter.</param>
		/// <returns>false</returns>
		public bool Contains(object key)
		{
			return false;
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		/// <param name="key">Doesn't matter.</param>
		public void Remove(object key)
		{
			// do nothing
		}

		/// <summary>
		/// Does nothing.
		/// </summary>
		public void Clear()
		{
			// do nothing
		}
		#endregion
	}
}
